import 'dart:math';

import 'base_model.dart';

class UserLimitItemModel {
  int id;
  int userId;
  int optType;
  int transactionType;
  int transactionId;
  int gotNum;
  int costNum;
  int status;
  String desc;
  int createdTime;
  int updatedTime;

  UserLimitItemModel.fromJson(Map<String, dynamic> data) {
    id = data["id"];
    userId = data["user_id"];
    optType = data["opt_type"];
    transactionType = data["transaction_type"];
    transactionId = data["transaction_id"];
    gotNum = data["got_num"];
    costNum = data["cost_num"];
    status = data["status"];
    desc = data["desc"];
    createdTime = data["created_time"];
    updatedTime = data["updated_time"];
  }
}

class UserLimitModel extends BaseModel {
  PagerModel pager = PagerModel.fromJson({});
  List<UserLimitItemModel> data = [];
  UserLimitModel.fromJson(Map<String, dynamic> res) : super.fromJson(res) {
    pager = PagerModel.fromJson(res["pager"] ?? {});
    final _random = new Random();
    final _date = new DateTime.now().millisecondsSinceEpoch;
    List list = res["data"] ?? [];
    // List list = [
    //       {
    //         'id': _random.nextInt(10000),
    //         'user_id': _random.nextInt(10000),
    //         'opt_type': 1,
    //         'transaction_type': 2,
    //         'transaction_id': 1,
    //         'got_num': 222,
    //         'cost_num': 3242,
    //         'status': 1,
    //         'desc': '这是测试数据',
    //         'created_time': _date,
    //         'updated_time': _date,
    //       }
    //     ];
    list.forEach((item) {
      data.add(UserLimitItemModel.fromJson(item));
    });
  }
  @override
  Map<String, dynamic> toJson() {
    return {'pager': pager, 'data': data};
  }
}
